<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:util="http://xmlns.jcp.org/jsf/composite/util">

    <p:confirmDialog global="true">
        <p:commandButton value="Da" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
        <p:commandButton value="Nu" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
    </p:confirmDialog>

    <h:form id="citizens_form">
        <util:dataTableWrapper title="Lista cetatenii">
            <f:facet name="buttonContent">
                <p:commandButton icon="custom-icon-add" value="Adauga cetatenie"
                                 oncomplete="PF('add_citizen_WV').show()" update=":create_citizen_form"
                                 resetValues="true"
                                 actionListener="#{additionalDataBean.resetCreateCitizenDialog}"/>
            </f:facet>
            <p:dataTable var="c" value="#{additionalDataBean.citizens}"
                         emptyMessage="Nu a fost gasita nici o inregistrare.">

                <p:column headerText="Denumire cetatenie">
                    <h:outputText value="#{c.citizenship.name}"/>
                </p:column>

                <p:column styleClass="override-icons" headerText="Actions">
                    <p:commandButton icon="custom-icon-edit"
                                     actionListener="#{additionalDataBean.initEditCitizenDialog(c)}"
                                     oncomplete="PF('add_citizen_WV').show()" update=":create_citizen_form"/>

                    <p:commandButton icon="custom-icon-delete"
                                     actionListener="#{additionalDataBean.deleteCitizen(c)}"
                                     update="@form">
                        <p:confirm header="Confirma"
                                   message="Sunteti sigur ca doriti stergerea cetateniei?"
                                   icon="ui-icon-alert"/>
                    </p:commandButton>

                </p:column>
            </p:dataTable>
        </util:dataTableWrapper>
    </h:form>

    <h:form id="documents_form">
        <util:dataTableWrapper title="Lista acte de identitate">
            <f:facet name="buttonContent">
                <p:commandButton icon="custom-icon-add" value="Adauga act de identitate"
                                 oncomplete="PF('add_document_WV').show()" update=":create_document_form"
                                 resetValues="true"
                                 actionListener="#{additionalDataBean.resetCreateDocumentDialog}"/>
            </f:facet>
            <p:dataTable var="d" value="#{additionalDataBean.documents}"
                         emptyMessage="Nu a fost gasita nici o inregistrare.">

                <p:column headerText="Document">
                    <h:outputText value="#{d.documentType.name}"/>
                </p:column>

                <p:column headerText="Seria/Numarul">
                    <h:outputText value="#{d.number}"/>
                </p:column>

                <p:column headerText="Domiciliul">
                    <h:outputText value="#{d.residenceVisa}"/>
                </p:column>

                <p:column headerText="Data emiterii">
                    <h:outputText value="#{d.issueDate}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column headerText="Autoritatea emitenta">
                    <h:outputText value="#{d.office}"/>
                </p:column>

                <p:column styleClass="override-icons" headerText="Actions">
                    <p:commandButton icon="custom-icon-edit"
                                     actionListener="#{additionalDataBean.initEditDocumentDialog(d)}"
                                     oncomplete="PF('add_document_WV').show()" update=":create_document_form"/>

                    <p:commandButton icon="custom-icon-delete"
                                     actionListener="#{additionalDataBean.deleteDocument(d)}"
                                     update="@form">
                        <p:confirm header="Confirma"
                                   message="Sunteti sigur ca doriti stergerea actului de identitate?"
                                   icon="ui-icon-alert"/>
                    </p:commandButton>

                </p:column>
            </p:dataTable>
        </util:dataTableWrapper>

    </h:form>

    <h:form id="family_members_form">
        <util:dataTableWrapper title="Lista membri de familie">
            <f:facet name="buttonContent">
                <p:commandButton icon="custom-icon-add" value="Adauga membru de familie"
                                 oncomplete="PF('add_family_WV').show()" update=":create_family_form"
                                 resetValues="true"
                                 actionListener="#{additionalDataBean.resetCreateFamilyDialog}"/>
            </f:facet>
            <p:dataTable var="f" value="#{additionalDataBean.familyMembers}"
                         emptyMessage="Nu a fost gasita nici o inregistrare.">

                <p:column headerText="Grad de rudenie">
                    <h:outputText value="#{f.familyRelation.name}"/>
                </p:column>

                <p:column headerText="Nume">
                    <h:outputText value="#{f.name}"/>
                </p:column>

                <p:column headerText="Data nasterii">
                    <h:outputText value="#{f.birthDate}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column styleClass="override-icons" headerText="Actions">
                    <p:commandButton icon="custom-icon-edit"
                                     actionListener="#{additionalDataBean.initEditFamilyMemberDialog(f)}"
                                     oncomplete="PF('add_family_WV').show()" update=":create_family_form"/>

                    <p:commandButton icon="custom-icon-delete"
                                     actionListener="#{additionalDataBean.deleteFamilyMember(f)}"
                                     update="@form">
                        <p:confirm header="Confirma"
                                   message="Sunteti sigur ca doriti stergerea membrului de familie?"
                                   icon="ui-icon-alert"/>
                    </p:commandButton>

                </p:column>
            </p:dataTable>
        </util:dataTableWrapper>
    </h:form>
</ui:composition>